<template>
  <div>
      <h1>当前求和为：{{num}}</h1>
      <select v-model.number="addNumTotal">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
      </select>
      <button @click="addNum">+</button>
      <button @click="cutNum">-</button>
      <button @click="oddAddNum">当前和为奇数再加</button>
      <button @click="waitAddNum">等一等再加</button>
  </div>
</template>

<script>
export default {
    data(){
    return {
      num:0,
      addNumTotal:1,
      timer:''
    }
  },
  components:{
      
  },
  methods: {
    addNum(){
      this.num += this.addNumTotal;
    },
    cutNum(){
      this.num -= this.addNumTotal;
    },
    oddAddNum(){
      if(this.num%2) this.num += this.addNumTotal;
    },
    waitAddNum(){
      this.timer = setTimeout(() => {
        this.num += this.addNumTotal;
      }, 500);
    }
  },
}
</script>

<style scoped>
 
</style>